package com.huabo.model;

import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import com.huabo.base.BaseModel;
import org.joda.time.DateTime;

import javax.persistence.*;
import java.io.Serializable;
import java.util.Date;

@Entity
@Table(name = "TC_LOGIN_LOG")
public class LoginLog extends BaseModel implements Serializable {

    /**
     * <p>Field serialVersionUID: 序列号</p>
     */
    private static final long serialVersionUID = 1L;

    //主键
    @Id
    @Column(name = "F_ID")
	@JsonSerialize(using = ToStringSerializer.class)
    private Long id;
    
    //用户标识
    @Column(name = "F_USERID")
	@JsonSerialize(using = ToStringSerializer.class)
    private Long userId;
    
    //用户名称
    @Column(name = "F_POLICENO")
    private String policeNo;
    
    //用户姓名
    @Column(name = "F_NAME")
    private String name;

    //登录时间
    @Temporal(TemporalType.TIMESTAMP)
    @Column(name = "F_LOGINTIME")
    private Date loginTime;
    
    //登出时间
    @Temporal(TemporalType.TIMESTAMP)
    @Column(name = "F_LOGOUTTIME")
    private Date logoutTime;
    //
    @Column(name = "F_LOGINTYPE")
    private String loginType;

    //
    @Column(name = "F_STATE")
    private String state;

    //失败原因
    @Column(name = "F_ERRORMESSAGE")
    private String errorMessage;

    //
    @Column(name = "F_LOGINIP")
    private String loginIp;

   
    public String getloginTimeStr() {
        if (loginTime != null) {
            return new DateTime(loginTime).toString("yyyy-MM-dd HH:mm:ss");
        }
        return null;
    }
    
    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

	public Long getUserId() {
		return userId;
	}

	public void setUserId(Long userId) {
		this.userId = userId;
	}

	public String getPoliceNo() {
		return policeNo;
	}

	public void setPoliceNo(String policeNo) {
		this.policeNo = policeNo;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public Date getLoginTime() {
		return loginTime;
	}

	public void setLoginTime(Date loginTime) {
		this.loginTime = loginTime;
	}

	public Date getLogoutTime() {
		return logoutTime;
	}

	public void setLogoutTime(Date logoutTime) {
		this.logoutTime = logoutTime;
	}

	public String getLoginType() {
		return loginType;
	}

	public void setLoginType(String loginType) {
		this.loginType = loginType;
	}

	public String getState() {
		return state;
	}

	public void setState(String state) {
		this.state = state;
	}

	public String getErrorMessage() {
		return errorMessage;
	}

	public void setErrorMessage(String errorMessage) {
		this.errorMessage = errorMessage;
	}

	public String getLoginIp() {
		return loginIp;
	}

	public void setLoginIp(String loginIp) {
		this.loginIp = loginIp;
	}

    
}